/**
 * 
 */
package com.elifes.hsj.client.netty.task;

import org.apache.log4j.Logger;

import com.elifes.hsj.packet.IPacket;

/**
 * 
 * 描述：
 * @author yangqiang
 *
 */
public class BaseTask implements ITask{
	private static final Logger logger = Logger.getLogger(BaseTask.class);
	/* (non-Javadoc)
	 * @see com.elifes.hsj.client.netty.task.ITask#handleResponse(java.lang.String, com.elifes.hsj.packet.IPacket)
	 */
	public void handleResponse(String responseMsg, IPacket packet) {
		if(responseMsg.startsWith("0")){//成功，设置返回结果
			handleSuccess(responseMsg, packet);
		} else {//失败，返回错误信息
			handleFail(responseMsg, packet);
		}
	}
	
	protected void handleSuccess(String responseMsg, IPacket packet){
		packet.setResult(true);
	}
	
	protected void handleFail(String responseMsg, IPacket packet){
		packet.setResult(false);
		packet.setExceptionMessage(responseMsg);
	}
}
